/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using Amazon.ECS;
using Amazon.ECS.Model;

namespace Amazon.ECS.Samples
{

    /// <summary>
    /// Seller Listing Search  Samples
    /// </summary>
    public class SellerListingSearchSample
    {
    
                                                                                         
        /// <summary>
        /// 
        /// <p/>
        /// The SellerListingSearch operation enables you to search for items offered
        /// by specific sellers. You cannot use SellerListingSearch to look up items sold by merchants.
        /// To look up an item sold by a merchant, use  ItemLookup   or  ItemSearch
        /// along with the MerchantId parameter.
        /// <p/>
        /// SellerListingSearch returns the listing ID or exchange ID of an item.
        /// Typically, you use those values with SellerListingLookup to find out more about those items.
        /// <p/>
        /// Each SellerListingSearch request returns up to ten items. By default, the first ten
        /// items are returned. You can use the ListingPage parameter to retrieve additional pages
        /// of (up to) ten listings.
        /// <p/>
        /// To use ECS, sellers must have less than 100,000 items for sale. Sellers that have more
        /// items for sale should use, instead of ECS, other seller APIs, including the Amazon
        /// Inventory Management System, and the Merchant@ API.
        /// <p/>
        /// <b>Available Response Groups</b>:
        /// <ul>
        /// <li>Request</li>
        /// <li>SellerListing</li>
        /// </ul>
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonECS service</param>
        /// <param name="request">SellerListingSearch request</param>
        public static void InvokeSellerListingSearch(AmazonECS service, params SellerListingSearchRequest [] request) 
        {
            try 
            {
                SellerListingSearchResponse response = service.SellerListingSearch(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        SellerListingSearchResponse");
                if (response.IsSetOperationRequest()) 
                {
                    Console.WriteLine("            OperationRequest");
                    OperationRequest  operationRequest = response.OperationRequest;
                    if (operationRequest.IsSetHTTPHeaders()) 
                    {
                        Console.WriteLine("                HTTPHeaders");
                        HTTPHeaders  HTTPHeaders = operationRequest.HTTPHeaders;
                    } 
                    if (operationRequest.IsSetRequestId()) 
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", operationRequest.RequestId);
                    }
                    if (operationRequest.IsSetArguments()) 
                    {
                        Console.WriteLine("                Arguments");
                        Arguments  arguments = operationRequest.Arguments;
                    } 
                    if (operationRequest.IsSetRequestProcessingTime()) 
                    {
                        Console.WriteLine("                RequestProcessingTime");
                        Console.WriteLine("                    {0}", operationRequest.RequestProcessingTime);
                    }
                } 
                List<SellerListings> sellerListingsList = response.SellerListings;
                foreach (SellerListings sellerListings in sellerListingsList) 
                {
                    Console.WriteLine("            SellerListings");
                    if (sellerListings.IsSetTotalResults()) 
                    {
                        Console.WriteLine("                TotalResults");
                        Console.WriteLine("                    {0}", sellerListings.TotalResults);
                    }
                    if (sellerListings.IsSetTotalPages()) 
                    {
                        Console.WriteLine("                TotalPages");
                        Console.WriteLine("                    {0}", sellerListings.TotalPages);
                    }
                    List<SellerListing> sellerListingList = sellerListings.SellerListing;
                    foreach (SellerListing sellerListing in sellerListingList) 
                    {
                        Console.WriteLine("                SellerListing");
                        if (sellerListing.IsSetExchangeId()) 
                        {
                            Console.WriteLine("                    ExchangeId");
                            Console.WriteLine("                        {0}", sellerListing.ExchangeId);
                        }
                        if (sellerListing.IsSetListingId()) 
                        {
                            Console.WriteLine("                    ListingId");
                            Console.WriteLine("                        {0}", sellerListing.ListingId);
                        }
                        if (sellerListing.IsSetASIN()) 
                        {
                            Console.WriteLine("                    ASIN");
                            Console.WriteLine("                        {0}", sellerListing.ASIN);
                        }
                        if (sellerListing.IsSetSKU()) 
                        {
                            Console.WriteLine("                    SKU");
                            Console.WriteLine("                        {0}", sellerListing.SKU);
                        }
                        if (sellerListing.IsSetUPC()) 
                        {
                            Console.WriteLine("                    UPC");
                            Console.WriteLine("                        {0}", sellerListing.UPC);
                        }
                        if (sellerListing.IsSetEAN()) 
                        {
                            Console.WriteLine("                    EAN");
                            Console.WriteLine("                        {0}", sellerListing.EAN);
                        }
                        if (sellerListing.IsSetWillShipExpedited()) 
                        {
                            Console.WriteLine("                    WillShipExpedited");
                            Console.WriteLine("                        {0}", sellerListing.WillShipExpedited);
                        }
                        if (sellerListing.IsSetWillShipInternational()) 
                        {
                            Console.WriteLine("                    WillShipInternational");
                            Console.WriteLine("                        {0}", sellerListing.WillShipInternational);
                        }
                        if (sellerListing.IsSetTitle()) 
                        {
                            Console.WriteLine("                    Title");
                            Console.WriteLine("                        {0}", sellerListing.Title);
                        }
                        if (sellerListing.IsSetPrice()) 
                        {
                            Console.WriteLine("                    Price");
                            Price  price = sellerListing.Price;
                            if (price.IsSetAmount()) 
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", price.Amount);
                            }
                            if (price.IsSetCurrencyCode()) 
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", price.CurrencyCode);
                            }
                            if (price.IsSetFormattedPrice()) 
                            {
                                Console.WriteLine("                        FormattedPrice");
                                Console.WriteLine("                            {0}", price.FormattedPrice);
                            }
                        } 
                        if (sellerListing.IsSetStartDate()) 
                        {
                            Console.WriteLine("                    StartDate");
                            Console.WriteLine("                        {0}", sellerListing.StartDate);
                        }
                        if (sellerListing.IsSetEndDate()) 
                        {
                            Console.WriteLine("                    EndDate");
                            Console.WriteLine("                        {0}", sellerListing.EndDate);
                        }
                        if (sellerListing.IsSetStatus()) 
                        {
                            Console.WriteLine("                    Status");
                            Console.WriteLine("                        {0}", sellerListing.Status);
                        }
                        if (sellerListing.IsSetQuantity()) 
                        {
                            Console.WriteLine("                    Quantity");
                            Console.WriteLine("                        {0}", sellerListing.Quantity);
                        }
                        if (sellerListing.IsSetCondition()) 
                        {
                            Console.WriteLine("                    Condition");
                            Console.WriteLine("                        {0}", sellerListing.Condition);
                        }
                        if (sellerListing.IsSetSubCondition()) 
                        {
                            Console.WriteLine("                    SubCondition");
                            Console.WriteLine("                        {0}", sellerListing.SubCondition);
                        }
                        if (sellerListing.IsSetSeller()) 
                        {
                            Console.WriteLine("                    Seller");
                            Seller  seller = sellerListing.Seller;
                            if (seller.IsSetSellerId()) 
                            {
                                Console.WriteLine("                        SellerId");
                                Console.WriteLine("                            {0}", seller.SellerId);
                            }
                            if (seller.IsSetSellerName()) 
                            {
                                Console.WriteLine("                        SellerName");
                                Console.WriteLine("                            {0}", seller.SellerName);
                            }
                            if (seller.IsSetSellerLegalName()) 
                            {
                                Console.WriteLine("                        SellerLegalName");
                                Console.WriteLine("                            {0}", seller.SellerLegalName);
                            }
                            if (seller.IsSetNickname()) 
                            {
                                Console.WriteLine("                        Nickname");
                                Console.WriteLine("                            {0}", seller.Nickname);
                            }
                            if (seller.IsSetGlancePage()) 
                            {
                                Console.WriteLine("                        GlancePage");
                                Console.WriteLine("                            {0}", seller.GlancePage);
                            }
                            if (seller.IsSetAbout()) 
                            {
                                Console.WriteLine("                        About");
                                Console.WriteLine("                            {0}", seller.About);
                            }
                            if (seller.IsSetMoreAbout()) 
                            {
                                Console.WriteLine("                        MoreAbout");
                                Console.WriteLine("                            {0}", seller.MoreAbout);
                            }
                            if (seller.IsSetLocation()) 
                            {
                                Console.WriteLine("                        Location");
                                SellerLocation  location = seller.Location;
                                if (location.IsSetUserDefinedLocation()) 
                                {
                                    Console.WriteLine("                            UserDefinedLocation");
                                    Console.WriteLine("                                {0}", location.UserDefinedLocation);
                                }
                                if (location.IsSetCity()) 
                                {
                                    Console.WriteLine("                            City");
                                    Console.WriteLine("                                {0}", location.City);
                                }
                                if (location.IsSetState()) 
                                {
                                    Console.WriteLine("                            State");
                                    Console.WriteLine("                                {0}", location.State);
                                }
                                if (location.IsSetCountry()) 
                                {
                                    Console.WriteLine("                            Country");
                                    Console.WriteLine("                                {0}", location.Country);
                                }
                            } 
                            if (seller.IsSetAverageFeedbackRating()) 
                            {
                                Console.WriteLine("                        AverageFeedbackRating");
                                Console.WriteLine("                            {0}", seller.AverageFeedbackRating);
                            }
                            if (seller.IsSetTotalFeedback()) 
                            {
                                Console.WriteLine("                        TotalFeedback");
                                Console.WriteLine("                            {0}", seller.TotalFeedback);
                            }
                            if (seller.IsSetTotalFeedbackPages()) 
                            {
                                Console.WriteLine("                        TotalFeedbackPages");
                                Console.WriteLine("                            {0}", seller.TotalFeedbackPages);
                            }
                            if (seller.IsSetSellerFeedbackSummary()) 
                            {
                                Console.WriteLine("                        SellerFeedbackSummary");
                                SellerFeedbackSummary  sellerFeedbackSummary = seller.SellerFeedbackSummary;
                                List<FeedbackDateRange> feedbackDateRangeList = sellerFeedbackSummary.FeedbackDateRange;
                                foreach (FeedbackDateRange feedbackDateRange in feedbackDateRangeList) 
                                {
                                    Console.WriteLine("                            FeedbackDateRange");
                                    List<SellerFeedbackRating> sellerFeedbackRatingList = feedbackDateRange.SellerFeedbackRating;
                                    foreach (SellerFeedbackRating sellerFeedbackRating in sellerFeedbackRatingList) 
                                    {
                                        Console.WriteLine("                                SellerFeedbackRating");
                                        if (sellerFeedbackRating.IsSetCount()) 
                                        {
                                            Console.WriteLine("                                    Count");
                                            Console.WriteLine("                                        {0}", sellerFeedbackRating.Count);
                                        }
                                        if (sellerFeedbackRating.IsSetPercentage()) 
                                        {
                                            Console.WriteLine("                                    Percentage");
                                            Console.WriteLine("                                        {0}", sellerFeedbackRating.Percentage);
                                        }
                                    }
                                }
                            } 
                            if (seller.IsSetSellerFeedback()) 
                            {
                                Console.WriteLine("                        SellerFeedback");
                                SellerFeedback  sellerFeedback = seller.SellerFeedback;
                                List<Feedback> feedbackList = sellerFeedback.Feedback;
                                foreach (Feedback feedback in feedbackList) 
                                {
                                    Console.WriteLine("                            Feedback");
                                    if (feedback.IsSetRating()) 
                                    {
                                        Console.WriteLine("                                Rating");
                                        Console.WriteLine("                                    {0}", feedback.Rating);
                                    }
                                    if (feedback.IsSetComment()) 
                                    {
                                        Console.WriteLine("                                Comment");
                                        Console.WriteLine("                                    {0}", feedback.Comment);
                                    }
                                    if (feedback.IsSetDate()) 
                                    {
                                        Console.WriteLine("                                Date");
                                        Console.WriteLine("                                    {0}", feedback.Date);
                                    }
                                    if (feedback.IsSetRatedBy()) 
                                    {
                                        Console.WriteLine("                                RatedBy");
                                        Console.WriteLine("                                    {0}", feedback.RatedBy);
                                    }
                                }
                            } 
                        } 
                    }
                }

            } 
            catch (AmazonECSException ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
                }
}
